package com.freesky.web.manager.remote;

import com.freesky.common.dao.entity.Member;
import com.freesky.common.pojo.DataTablesResult;
import com.freesky.common.pojo.Result;
import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.common.utils.reponse.JSONResponseDiretor;
import com.freesky.common.vo.VOMember;
import com.freesky.web.manager.remote.fallback.ImageRemoteFallback;
import com.freesky.web.manager.remote.fallback.MemberRemoteFallback;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(name = "emall-provider-zuul", fallback = MemberRemoteFallback.class)
public interface MemberRemote {
    String ZUUL_URL_PREFIX = "/mysevice/member";

    @GetMapping(value =ZUUL_URL_PREFIX+"/member/list")
    DataTablesResult getMemberList(
            @RequestParam(value = "draw") int draw,
            @RequestParam(value = "start") int start,
            @RequestParam(value = "length") int length,
            @RequestParam(value = "searchKey") String searchKey,
            @RequestParam(value = "minDate") String minDate,
            @RequestParam(value = "maxDate") String maxDate,
            @RequestParam(value = "search[value]") String search,
            @RequestParam(value = "order[0][column]") int orderCol,
            @RequestParam(value = "order[0][dir]") String orderDir);

    @GetMapping(value =ZUUL_URL_PREFIX+"/member/list/remove")
    DataTablesResult getDelMemberList(
            @RequestParam(value = "draw") int draw,
            @RequestParam(value = "start") int start,
            @RequestParam(value = "length") int length,
            @RequestParam(value = "searchKey") String searchKey,
            @RequestParam(value = "minDate") String minDate,
            @RequestParam(value = "maxDate") String maxDate,
            @RequestParam(value = "search[value]") String search,
            @RequestParam(value = "order[0][column]") int orderCol,
            @RequestParam(value = "order[0][dir]") String orderDir);

    @GetMapping(value =ZUUL_URL_PREFIX+"/member/count")
    DataTablesResult getMemberCount();

    @GetMapping(value =ZUUL_URL_PREFIX+"/member/count/remove")
    DataTablesResult getRemoveMemberCount();

    @PostMapping(value =ZUUL_URL_PREFIX+"/member/add")
    void createMember(@ModelAttribute VOMember voMember);

    @PutMapping(value =ZUUL_URL_PREFIX+ "/member/stop/{id}")
     JSONResponse stopMember(@PathVariable(value = "id") Long id);
    @PutMapping(value =ZUUL_URL_PREFIX+"/member/start/{ids}")
    JSONResponse startMember(@PathVariable(value = "ids") Long[] ids);

    @PutMapping(value =ZUUL_URL_PREFIX+"/member/remove/{ids}")
    JSONResponse removeMember(@PathVariable(value = "ids") Long[] ids);

    @DeleteMapping(value =ZUUL_URL_PREFIX+"/member/del/{ids}")
    JSONResponse deleteMember(@PathVariable(value = "ids") Long[] ids);

    @PostMapping(value =ZUUL_URL_PREFIX+"/member/change-password/{id}")
    JSONResponse changeMemberPassword(@PathVariable(value = "id") Long id, @ModelAttribute VOMember voMember);

    @PostMapping(value =ZUUL_URL_PREFIX+"/member/update/{id}")
    JSONResponse updateMember(@PathVariable(value = "id") Long id, @ModelAttribute VOMember voMember);

    @GetMapping(value =ZUUL_URL_PREFIX+"/member/{id}")
    Result<Member> getMemberById(@PathVariable(value = "id") Long id);

    @GetMapping(value =ZUUL_URL_PREFIX+"/member/username")
    Boolean validateUsername(@RequestParam(value = "username") String username);

    @GetMapping(value =ZUUL_URL_PREFIX+"/member/phone")
    Boolean validatePhone(@RequestParam(value = "phone") String phone);

    @GetMapping(value =ZUUL_URL_PREFIX+"/member/email")
    Boolean validateEmail(@RequestParam(value = "email") String email);

    @GetMapping(value =ZUUL_URL_PREFIX+"/member/edit/{id}/username")
    Boolean validateEditUsername(@PathVariable(value = "id") Long id, @RequestParam(value = "username") String username);

    @GetMapping(value =ZUUL_URL_PREFIX+"/member/edit/{id}/phone")
    Boolean validateEditPhone(@PathVariable(value = "id") Long id, @RequestParam(value = "phone") String phone);

    @GetMapping(value =ZUUL_URL_PREFIX+"/member/edit/{id}/email")
    Boolean validateEditEmail(@PathVariable(value = "id") Long id, @RequestParam(value = "email") String email);
}
